#pragma once
#include "DOMNode.h"

namespace Pattern
{
namespace DOM
{
	template<typename T>
	class PropertyAccessControl:public boost::noncopyable
	{
	protected:
		T _data;
		PropertyAccessControl()
		{

		}
	public:
		bool operator==(const PropertyAccessControl<T>& another)const
		{
			return _data == another._data;
		}

		bool operator!=(const PropertyAccessControl<T>& another)const
		{
			return _data != another._data;
		}
	};


	template<typename T>
	class ReadonlyAccessControl:PropertyAccessControl<T>
	{
	public:
		ReadonlyAccessControl()
		{

		}

		ReadonlyAccessControl(const T& value):_data(value)
		{
			
		}

		operator const T()
		{		
			return _data;
		}
	};

	template<typename T>
	class ReadWriteAccessControl: PropertyAccessControl<T>
	{
	public:
		ReadWriteAccessControl()
		{
			
		}

		ReadWriteAccessControl(const T& value):_data(value)
		{

		}

		operator const T()
		{		
			return _data;
		}

		void operator=(const T& v)
		{
			_data = v;
		}
	};

	template<typename HOST, typename T,typename ACCESS_CONTROL=ReadWriteAccessControl<T>>
	class Property:
		public DOMTag<HOST>
	{
	protected:
		ACCESS_CONTROL _ac;

	public:	
		Property(const HOST* pHost):DOMTag<HOST>(pHost)
		{

		}

		Property(const HOST* pHost,const T& v):DOMTag<HOST>(pHost),_ac(v)
		{
			
		}

		void operator=(const T& v)
		{
			_ac = v;
		}

		operator const T()
		{		
			return _ac;
		}
	};

}
}